home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* Balloon XCMD V1.0.1 */
- /* */
- /* Usage: balloon false -- switch help off */
- /* balloon true -- switch help on */
- /* balloon -- remove balloon */
- /* balloon helpString -- show balloon */
- /* */
- /* No balloon is shown if the mouseLoc is not within the target or a */
- /* previous balloon is visible. */
- /* Compile as: Code Resource, Type XCMD, Purgeable */
- /* Freeware written in Think C 5.0 by R. Geisler 1992. */
- /************************************************************************/
-
-
- #include <Balloons.h>
- #include <GestaltEqu.h>
- #include <HyperXCmd.h>
- #include <SetupA4.h>
- #include <string.h>
- #define retUnav "balloon help unavailable"
- #define retOff "balloon help off"
-
-
- HMMessageRecord myMsg=
- { khmmString };
- long ftr;
- Point tip;
- Rect aRect;
- Handle hit, pos;
-
-
- pascal main(XCmdPtr paramPtr)
- { RememberA0();
- SetUpA4();
- if(Gestalt(gestaltHelpMgrAttr, &ftr)||!(ftr&1<<gestaltHelpMgrPresent))
- { paramPtr->returnValue=NewHandle(sizeof(retUnav));
- strcpy(*paramPtr->returnValue, retUnav); } /* help unav. */
- else
- { if(!paramPtr->paramCount) /* remove balloon */
- HMRemoveBalloon();
- else if(!strcmp(*paramPtr->params[0], "true"))
- HMSetBalloons(true); /* switch help on */
- else if(!strcmp(*paramPtr->params[0], "false"))
- HMSetBalloons(false); /* switch help off */
- else if(!HMIsBalloon())
- { hit=EvalExpr(paramPtr,
- "\pthe mouseLoc is within the rect of the target");
- if(!strcmp("true", *hit)) /* show balloon */
- { pos=EvalExpr(paramPtr,
- "\pthe mouseV + the top of card window");
- tip.v=atoi(*pos);
- DisposHandle(pos);
- pos=EvalExpr(paramPtr,
- "\pthe mouseH + the left of card window");
- tip.h=atoi(*pos);
- DisposHandle(pos);
- pos=EvalExpr(paramPtr,
- "\pthe top of the target + the top of card window");
- aRect.top=atoi(*pos);
- DisposHandle(pos);
- pos=EvalExpr(paramPtr,
- "\pthe left of the target + the left of card window");
- aRect.left=atoi(*pos);
- DisposHandle(pos);
- pos=EvalExpr(paramPtr,
- "\pthe bottom of the target + the top of card window");
- aRect.bottom=atoi(*pos);
- DisposHandle(pos);
- pos=EvalExpr(paramPtr,
- "\pthe right of the target + the left of card window");
- aRect.right=atoi(*pos);
- DisposHandle(pos);
- ZeroToPas(paramPtr, *paramPtr->params[0],
- (StringPtr)myMsg.u.hmmString);
- HMShowBalloon(&myMsg, tip, &aRect, 0L, 0, 6,
- kHMSaveBitsWindow); }
- DisposHandle(hit); }
- if (!HMGetBalloons()) /* help is off */
- { paramPtr->returnValue=NewHandle(sizeof(retOff));
- strcpy(*paramPtr->returnValue, retOff); } }
- RestoreA4(); }